package feeinterface.utils;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.ulwx.tool.StringUtils;



public class PhoneUtils {
	private static Logger log = Logger.getLogger(PhoneUtils.class);
	public static Map<String,String> SmsPrefixForCarrier=new HashMap<String,String>();
	static{
		SmsPrefixForCarrier.put("130",	"联通");
		SmsPrefixForCarrier.put("131",	"联通");
		SmsPrefixForCarrier.put("132",	"联通");
		SmsPrefixForCarrier.put("133",	"电信");
		SmsPrefixForCarrier.put("134",	"移动");
		SmsPrefixForCarrier.put("135",	"移动");
		SmsPrefixForCarrier.put("136",	"移动");
		SmsPrefixForCarrier.put("137",	"移动");
		SmsPrefixForCarrier.put("138",	"移动");
		SmsPrefixForCarrier.put("139",	"移动");
		SmsPrefixForCarrier.put("145",	"联通");
		SmsPrefixForCarrier.put("147",	"移动");
		SmsPrefixForCarrier.put("150",	"移动");
		SmsPrefixForCarrier.put("151",	"移动");
		SmsPrefixForCarrier.put("152",	"移动");
		SmsPrefixForCarrier.put("153",	"电信");
		SmsPrefixForCarrier.put("155",	"联通");
		SmsPrefixForCarrier.put("156",	"联通");
		SmsPrefixForCarrier.put("157",	"移动");
		SmsPrefixForCarrier.put("158",	"移动");
		SmsPrefixForCarrier.put("159",	"移动");
		SmsPrefixForCarrier.put("182",	"移动");
		SmsPrefixForCarrier.put("183",	"移动");
		SmsPrefixForCarrier.put("186",	"联通");
		SmsPrefixForCarrier.put("187",	"移动");
		SmsPrefixForCarrier.put("188",	"移动");
		SmsPrefixForCarrier.put("189",	"电信");

	}
	
	public static String getCarrierFromPhone(String phone){
		String str=getAdjustedPhone(phone);
		String key=str.substring(0, 3);
		String carrier= StringUtils.trim(SmsPrefixForCarrier.get(key));
		if(StringUtils.isEmpty(carrier)){
			return "未知";
		}
		log.debug("运营商:"+carrier);
		return carrier;
		
	}
	public static String getAdjustedPhone(String phone){
		
		String newPhone=StringUtils.trimLeadingStrings(phone, 
				new String[]{"+186","86"," 86","+86"});
		return newPhone;
	}
	public static void main(String[] args) {
		System.out.println(getAdjustedPhone("861234"));
	}
}
